package com.hopu.bean.time;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class TimeTop10Shop implements Serializable, Comparable<TimeTop10Shop>  {

    private String hour;
    private String type;
    private String sid;
    private String sname;

    private int viewCount;
    private int cartCount;
    private int parchaseCount;

    public TimeTop10Shop(String hour, String type, String sid, String sname) {
        this.hour = hour;
        this.type = type;
        this.sid = sid;
        this.sname = sname;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TimeTop10Shop top10Shop = (TimeTop10Shop) o;
        return Objects.equals(sid, top10Shop.sid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid);
    }

    @Override
    public int compareTo(TimeTop10Shop o) {
        if (o.viewCount == this.viewCount) {
            if (o.cartCount == this.cartCount) {
                return o.parchaseCount - this.parchaseCount;
            } else {
                return o.cartCount - this.cartCount;
            }
        } else {
            return o.viewCount - this.viewCount;
        }
    }
}
